package com.boyuan.huijiaoyu;

import com.example.combinebitmap.NewGroupActivity;
import com.magicsoft.constant.Constant;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class PersonChatActivity extends Activity implements OnClickListener{

	private String mobile;
	private ImageView imag_tou;
	private DisplayImageOptions options;
	private ImageLoader imageLoader;
	private String name;
	private String contactID;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_person_chat);
		Intent intent = getIntent();
		contactID = intent.getStringExtra("contactID");
		mobile = intent.getStringExtra("mobile");
		name = intent.getStringExtra("name");
		initUI();
	}

	private void initUI() {
		findViewById(R.id.lay_back).setOnClickListener(this);
		findViewById(R.id.lay_add).setOnClickListener(this);
		TextView tv_name = (TextView) findViewById(R.id.textView2);
		tv_name.setText(name);
		imageLoader = ImageLoader.getInstance();
		imag_tou = (ImageView) findViewById(R.id.imag_tou1);
		options = new DisplayImageOptions.Builder()
		.showImageOnLoading(R.drawable.default_header)
		.showImageForEmptyUri(R.drawable.default_header)
		.showImageOnFail(R.drawable.default_header).cacheInMemory(true)
		.cacheOnDisc(true).considerExifParams(true)
		.build();
		String uri = Constant.photourl + contactID;
		imageLoader.displayImage(uri, imag_tou, options);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.person_chat, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.lay_back:
			finish();
			break;
		case R.id.lay_add:
			startActivity(new Intent(PersonChatActivity.this,NewGroupActivity.class).putExtra("mobile", mobile).putExtra("name", name).putExtra("contactID", contactID));
//			finish();
			break;
		default:
			break;
		}
	}

}
